<template>
  <div class="register">
    <h1>注册</h1>

    <div>
      <h5>账号</h5>
      <el-input v-model="account"></el-input>
    </div>

    <div>
      <h5>密码</h5>
      <el-input v-model="password" type="password"></el-input>
    </div>

    <div>
      <router-link to="/login">已经注册？</router-link>
      <!-- <router-link >找回密码</router-link> -->
    </div>

    <div>
      <el-button type="primary" round @click="reg">注册</el-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      account: "",
      password: ""
    };
  },
  methods: {
    // 注册
    reg() {
      if (this.account !== "" && this.password !== "") {
        console.log(this.account, this.password);

        this.axios.post('/user/register',{
          account : this.account,
          password : this.password,
        }).then( (res)=>{

          console.log(res);

          // 消息弹窗
          this.$notify({
            title: "成功",
            message: "成功注册",
            type: "success"
          });
          
        })






      } else {
        
        this.$notify({
          title: "注册失败",
          message: "请检查账号和密码是否按照要求",
          type: "error"
        });

      }
    }
  }
};
</script>




<style lang="scss" scoped>
.register {
  width: 450px;
  margin: 100px auto 0;
  border: 1px solid #ccc;
  border-radius: 10px;
  padding: 20px;
  .el-button {
    width: 50%;
    margin-top: 20px;
    margin-left: 25%;
  }
}
</style>

